/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MonHocInternalFrame.java
 *
 * Created on Jul 22, 2010, 1:40:41 AM
 */

package GUI;

import BUS.MonHocBUS;
import POJO.MonHocPOJO;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author DarkMagikian
 */
public class MonHocInternalFrame extends javax.swing.JInternalFrame {

    /** Trạng thái của hai button Thêm & Cập nhật */
    private boolean TrangThai;
    /*
     * TrangThai = true  => Thêm mới
     * TrangThai = false => Cập nhật
     */
    public void showList(){
        try{
            ArrayList<MonHocPOJO> list = MonHocBUS.selectAll();
            DefaultTableModel dtm = new DefaultTableModel() {
                @Override
                public boolean isCellEditable(int row, int column) {
                    return false;
                }
            };
            dtm.addColumn("STT");
            dtm.addColumn("Mã môn học");
            dtm.addColumn("Tên môn học");
            dtm.addColumn("Hệ số");
            int size = list.size();
            dtm.setRowCount(size);
            for(int i=0;i<size;i++){
                dtm.setValueAt(i+1, i, 0);
                dtm.setValueAt(list.get(i).getMaMonHoc(), i, 1);
                dtm.setValueAt(list.get(i).getTenMonHoc(), i, 2);
                dtm.setValueAt(list.get(i).getHeSo(), i, 3);
            }
            this.jTDanhSach.setModel(dtm);
            this.jTDanhSach.changeSelection(0, 0, false, false);
            this.jLThongTin.setText("Môn học đang lựa chọn");
            this.setInfo();
        }catch(Exception ex){
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }
    }

    public void setInfo(){
        int row = this.jTDanhSach.getSelectedRow();
        if(row>=0){
            this.jTFMaMonHoc.setText(this.jTDanhSach.getValueAt(row, 1).toString());
            this.jTFTenMonHoc.setText(this.jTDanhSach.getValueAt(row, 2).toString());
            this.jSHeSo.setValue(this.jTDanhSach.getValueAt(row, 3));
        }
    }

    public void setButton(boolean onoff){
        this.jBLuu.setEnabled(!onoff);
        this.jBHuyBo.setEnabled(!onoff);
        this.jBThem.setEnabled(onoff);
        this.jBXoa.setEnabled(onoff);
        this.jBCapNhat.setEnabled(onoff);
    }

    /** Creates new form MonHocInternalFrame */
    public MonHocInternalFrame() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPThongTin = new javax.swing.JPanel();
        jLThongTin = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jTFMaMonHoc = new javax.swing.JTextField();
        jTFTenMonHoc = new javax.swing.JTextField();
        jBLuu = new javax.swing.JButton();
        jBHuyBo = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jSHeSo = new javax.swing.JSpinner();
        jPDanhSach = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTDanhSach = new javax.swing.JTable();
        jBThem = new javax.swing.JButton();
        jBXoa = new javax.swing.JButton();
        jBCapNhat = new javax.swing.JButton();
        jBLamMoi = new javax.swing.JButton();
        jBThoat = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel3 = new javax.swing.JLabel();

        setClosable(true);
        setIconifiable(true);
        setTitle("Quản lý học sinh - Danh sách môn học");
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameOpened(evt);
            }
        });

        jPThongTin.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Thông tin", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 51, 255))); // NOI18N

        jLThongTin.setText("Môn học đang lựa chọn");

        jLabel2.setText("Mã môn học:");

        jLabel4.setText("Tên môn học:");

        jTFMaMonHoc.setEnabled(false);

        jTFTenMonHoc.setEnabled(false);
        jTFTenMonHoc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTFTenMonHocActionPerformed(evt);
            }
        });

        jBLuu.setText("Lưu");
        jBLuu.setEnabled(false);
        jBLuu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBLuuActionPerformed(evt);
            }
        });

        jBHuyBo.setText("Hủy bỏ");
        jBHuyBo.setEnabled(false);
        jBHuyBo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBHuyBoActionPerformed(evt);
            }
        });

        jLabel1.setText("Hệ số:");

        jSHeSo.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1), Integer.valueOf(1), null, Integer.valueOf(1)));
        jSHeSo.setEnabled(false);

        javax.swing.GroupLayout jPThongTinLayout = new javax.swing.GroupLayout(jPThongTin);
        jPThongTin.setLayout(jPThongTinLayout);
        jPThongTinLayout.setHorizontalGroup(
            jPThongTinLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPThongTinLayout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(jPThongTinLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPThongTinLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(jPThongTinLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel2)
                            .addComponent(jLabel1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPThongTinLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTFMaMonHoc, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)
                            .addComponent(jSHeSo, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTFTenMonHoc, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(28, 28, 28)
                        .addGroup(jPThongTinLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jBHuyBo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jBLuu, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)))
                    .addComponent(jLThongTin))
                .addContainerGap(22, Short.MAX_VALUE))
        );
        jPThongTinLayout.setVerticalGroup(
            jPThongTinLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPThongTinLayout.createSequentialGroup()
                .addComponent(jLThongTin)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPThongTinLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTFMaMonHoc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jBLuu))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPThongTinLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTFTenMonHoc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jBHuyBo))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPThongTinLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jSHeSo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPDanhSach.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Danh sách", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 51, 255))); // NOI18N

        jTDanhSach.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jTDanhSach.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jTDanhSach.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTDanhSachMouseClicked(evt);
            }
        });
        jTDanhSach.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTDanhSachKeyReleased(evt);
            }
        });
        jScrollPane1.setViewportView(jTDanhSach);

        jBThem.setText("Thêm");
        jBThem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBThemActionPerformed(evt);
            }
        });

        jBXoa.setText("Xóa");
        jBXoa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBXoaActionPerformed(evt);
            }
        });

        jBCapNhat.setText("Cập nhật");
        jBCapNhat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBCapNhatActionPerformed(evt);
            }
        });

        jBLamMoi.setText("Làm mới");
        jBLamMoi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBLamMoiActionPerformed(evt);
            }
        });

        jBThoat.setText("Thoát");
        jBThoat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBThoatActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPDanhSachLayout = new javax.swing.GroupLayout(jPDanhSach);
        jPDanhSach.setLayout(jPDanhSachLayout);
        jPDanhSachLayout.setHorizontalGroup(
            jPDanhSachLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPDanhSachLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 255, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPDanhSachLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jBThoat, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jBLamMoi, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jBXoa, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jBCapNhat, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jBThem, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPDanhSachLayout.setVerticalGroup(
            jPDanhSachLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPDanhSachLayout.createSequentialGroup()
                .addGroup(jPDanhSachLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE)
                    .addGroup(jPDanhSachLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jBThem, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jBXoa, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jBCapNhat, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(44, 44, 44)
                        .addComponent(jBLamMoi)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jBThoat, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 24));
        jLabel3.setForeground(new java.awt.Color(0, 102, 255));
        jLabel3.setText("Danh sách môn học");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.CENTER, javax.swing.GroupLayout.DEFAULT_SIZE, 390, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jPDanhSach, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPThongTin, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPThongTin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPDanhSach, javax.swing.GroupLayout.PREFERRED_SIZE, 227, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jBThoatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBThoatActionPerformed
        // TODO add your handling code here:
        int xacnhan = JOptionPane.showConfirmDialog(this, "Bạn thực sự muốn thoát", "Xác nhận", JOptionPane.YES_NO_OPTION);
        if(xacnhan==0){
            this.dispose();
        }
}//GEN-LAST:event_jBThoatActionPerformed

    private void jBLuuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBLuuActionPerformed
        // TODO add your handling code here:
        boolean kq = false;
        String error_message = "";
        boolean error = false;

        String MaMH = this.jTFMaMonHoc.getText();
        String TenMH = this.jTFTenMonHoc.getText();
        String HeSo = this.jSHeSo.getValue().toString();

        if (this.TrangThai) {
            int n = this.jTDanhSach.getRowCount();
            for(int i=0;i<n;i++){
                if(this.jTFMaMonHoc.getText().compareToIgnoreCase(this.jTDanhSach.getValueAt(i, 1).toString())==0){
                    error = true;
                    error_message += "Mã môn học đã tồn tại.\n";
                    this.jTFMaMonHoc.requestFocus();
                    this.jTFMaMonHoc.selectAll();
                    break;
                }
            }
            if (MaMH.isEmpty()) {
                error_message += "Mã môn học không được để trống.\n";
                error = true;
            }
            if (TenMH.isEmpty()) {
                error_message += "Tên môn học không được để trống.\n";
                error = true;
            }
            if(error){
                JOptionPane.showMessageDialog(this, error_message, "Thông báo", JOptionPane.ERROR_MESSAGE);
            } else {
                kq = MonHocBUS.insert(MaMH, TenMH, HeSo);
                if (kq) {
                    JOptionPane.showMessageDialog(this, "Thêm thành công.");
                } else {
                    JOptionPane.showMessageDialog(this, "Thêm thất bại");
                }
                this.setButton(true);
                this.jTFMaMonHoc.setEnabled(false);
                this.jTFTenMonHoc.setEnabled(false);
                this.jSHeSo.setEnabled(false);
                this.showList();
            }
        }else{
            int row = this.jTDanhSach.getSelectedRow();
            if(this.jTFTenMonHoc.getText().equals(this.jTDanhSach.getValueAt(row, 2).toString())
              && this.jSHeSo.getValue().equals(this.jTDanhSach.getValueAt(row, 3))){
                JOptionPane.showMessageDialog(this, "Không có sự thay đổi", "Thông báo", JOptionPane.WARNING_MESSAGE);
            }else{
                kq = MonHocBUS.update(MaMH, TenMH, HeSo);
                if (kq) {
                    JOptionPane.showMessageDialog(this, "Cập nhật thành công.");
                } else {
                    JOptionPane.showMessageDialog(this, "Cập nhật thất bại");
                }
                this.setButton(true);
                this.jTFMaMonHoc.setEnabled(false);
                this.jTFTenMonHoc.setEnabled(false);
                this.jSHeSo.setEnabled(false);
                this.showList();
            }
        }
}//GEN-LAST:event_jBLuuActionPerformed

    private void jBHuyBoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBHuyBoActionPerformed
        // TODO add your handling code here:
        this.setButton(true);
        this.jTFTenMonHoc.setEnabled(false);
        this.jTFMaMonHoc.setEnabled(false);
        this.jSHeSo.setEnabled(false);
        this.showList();
}//GEN-LAST:event_jBHuyBoActionPerformed

    private void jTDanhSachMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTDanhSachMouseClicked
        // TODO add your handling code here:
        this.setInfo();
}//GEN-LAST:event_jTDanhSachMouseClicked

    private void jBXoaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBXoaActionPerformed
        // TODO add your handling code here:

        int xacnhan = JOptionPane.showConfirmDialog(this, "Bạn thực sự muốn xóa môn '"+this.jTFTenMonHoc.getText()+"' ?", "Xác nhận", JOptionPane.YES_NO_OPTION);
        if(xacnhan==0){
            boolean kq = MonHocBUS.delete(this.jTFMaMonHoc.getText());
            if (kq==false) {
                JOptionPane.showMessageDialog(this, "Xóa thất bại");
            }
            this.showList();
        }
}//GEN-LAST:event_jBXoaActionPerformed

    private void jBCapNhatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBCapNhatActionPerformed
        // TODO add your handling code here:
        this.jLThongTin.setText("Cập nhật tên môn học");
        this.jTFTenMonHoc.setEnabled(true);
        this.jSHeSo.setEnabled(true);
        this.jTFTenMonHoc.requestFocus();
        this.jTFTenMonHoc.selectAll();

        this.setButton(false);

        this.TrangThai = false;
}//GEN-LAST:event_jBCapNhatActionPerformed

    private void jBThemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBThemActionPerformed
        // TODO add your handling code here:
        this.jLThongTin.setText("Thêm môn học mới");
        this.jTFMaMonHoc.setEnabled(true);
        this.jTFMaMonHoc.setText(null);
        this.jTFTenMonHoc.setEnabled(true);
        this.jTFTenMonHoc.setText(null);
        this.jSHeSo.setEnabled(true);
        this.jSHeSo.setValue(1);
        this.jTFMaMonHoc.requestFocus();

        this.setButton(false);

        this.TrangThai = true;
}//GEN-LAST:event_jBThemActionPerformed

    private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameOpened
        // TODO add your handling code here:
        this.showList();
    }//GEN-LAST:event_formInternalFrameOpened

    private void jBLamMoiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBLamMoiActionPerformed
        // TODO add your handling code here:
        this.showList();
    }//GEN-LAST:event_jBLamMoiActionPerformed

    private void jTDanhSachKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTDanhSachKeyReleased
        // TODO add your handling code here:
        if(evt.getKeyCode()==38 || evt.getKeyCode()==40)  this.setInfo();
        if(evt.getKeyCode()==127)  this.jBXoaActionPerformed(null);
    }//GEN-LAST:event_jTDanhSachKeyReleased

    private void jTFTenMonHocActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTFTenMonHocActionPerformed
        // TODO add your handling code here:
        this.jBLuuActionPerformed(null);
    }//GEN-LAST:event_jTFTenMonHocActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBCapNhat;
    private javax.swing.JButton jBHuyBo;
    private javax.swing.JButton jBLamMoi;
    private javax.swing.JButton jBLuu;
    private javax.swing.JButton jBThem;
    private javax.swing.JButton jBThoat;
    private javax.swing.JButton jBXoa;
    private javax.swing.JLabel jLThongTin;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPDanhSach;
    private javax.swing.JPanel jPThongTin;
    private javax.swing.JSpinner jSHeSo;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTable jTDanhSach;
    private javax.swing.JTextField jTFMaMonHoc;
    private javax.swing.JTextField jTFTenMonHoc;
    // End of variables declaration//GEN-END:variables

}
